<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
</head>

<body>

</body>
<script type="text/javascript">
    //取出admin和123
    var str = "http://www.baidu.com?name=admin&pwd=123";
    var stra = str.split("?");
    var strb = stra[1].split("&");
    // var strc = strb.split("=");
    console.log(strb);
    //任意给定一串字母，统计字符串里面的大写字母小写字母数字以及其它字符的个数
    var s = "yyue%#%#%dfdf546464AAD";
    var upper = 0;
    var lower = 0;
    var num1 = 0;
    var qt = 0;
    var c = null;
    // 0-48 65 
    for (var i = 0; i < s.length; i++) {
        if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z') {
            upper++;
        } else if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z') {
            lower++;
        } else if (s.charAt(i) >= '0' && s.charAt(i) <= '9') {
            num1++;
        } else {
            qt++;
        }
    }
    console.log('小写字母 ', lower);
    console.log('大写字母 ', upper);
    console.log('数字 ', num1);
    console.log('其他字符 ', qt);

    // 随机产生四个大写或小写或数字组成的验证码
    var nums = "QWERTYUIOPLKJHGFDSAZXCVBNMqwertyuioplkjhgfdsazxcvbnm1234567890";
    var yzm = "";
    for (var i = 1; i <= 4; i++) {
        var n = Math.floor((Math.random() * nums.length) + 1);
        var m = nums.charAt(n);
        if (yzm.indexOf(m) != -1) {
            i--;
            continue;
        }
        yzm += m;
    }
    console.log('验证码 ', yzm);

    // 编写程序实现字符串的加密操作，要求：输入字符串，字符串的奇数位抽出来做前半部分，偶数位倒序后做后半部分拼接起来形成一个新的字符串输出
    var s1 = "mnbvhutesfglout8643";
    // console.log('加密之前 ',s1); 
    var qi = "";
    var ou = "";
    for (var i = 0; i < s1.length; i++) {
        if (i % 2 == 0) {
            ou += s1.charAt(i);
        } else {
            qi += s1.charAt(i);
        }
    }
    console.log(ou + qi.split("").reverse().join(""));
    var ouu = "";
    for (var i = ou.length - 1; i >= 0; i--) {
        ouu += ou[i];
    }
    console.log('加密之后', qi.concat(ouu));

    var s1 = "hello thank funny hello what suck it dick thank hello";
    var obj = {};
    var s2 = s1.split(" ");
    console.log(s2);
    s2.forEach(function(item) {
        if (obj[item]) {
            obj[item] += 1;
        } else {
            obj[item] = 1;
        }
    });
    console.log(obj);
</script>

</html>